package com.xiang.xian.array;

/**
 * @Author Xiang.Xian
 * @Description
 * @Date 2025/01/10/14:47
 * @Version 1.0
 */
public class PalindromeString {

    public static void main(String[] args) {
        String str = "ABA";
        String str2 = "ABAAAAC";
        String str3 = "ABABA";
        String str4 = "ABAC";

        System.out.println(str + ": "+isPalindromeString(str));
        System.out.println(str2 + ": "+isPalindromeString(str2));
        System.out.println(str3 + ": "+isPalindromeString(str3));
        System.out.println(str4 + ": "+isPalindromeString(str4));

    }

    public static boolean isPalindromeString(String str) {
        char[] charArray = str.toCharArray();
        int j = charArray.length - 1;
        for (int i = 0; i < charArray.length; i++) {
            if (charArray[i] != charArray[j]) {
                return Boolean.FALSE;
            }
            j--;
        }
        return Boolean.TRUE;
    }
}
